/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software Foundation,
 *    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

package JET.Frames.DataModels;

import JET.Centers.ControlCenter;
import java.util.ArrayList;
import javax.swing.ListModel;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;

/**
 *
 * @author 057Ry
 */
public class ActionsListModel implements ListModel
{

    static final ControlCenter CC = ControlCenter.getInstance();
    ArrayList<ListDataListener> listeners;

    public ActionsListModel() {
        listeners = new ArrayList<ListDataListener>();
    }

    public int getSize()
    {
        if (CC != null)
            return CC.AC.getActionsCount();
        else
            return 0;
    }

    public Object getElementAt(int index)
    {
        if (CC!=null)
            return ""+CC.AC.getAction(index);
        else
            return null;
    }

    public void fireAtcionsListChanged()
    {
        for(ListDataListener l : listeners)
            l.contentsChanged(new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED,0,getSize()-1));
    }

    public void addListDataListener(ListDataListener l) {
        listeners.add(l);
    }

    public void removeListDataListener(ListDataListener l) {
        listeners.remove(l);
    }

}
